

/*
	Base Business Objects.
	(C) Lehavi Solutions	

*/
	
#region using	
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
#endregion


namespace BO
{	
	
	[Serializable]
	public partial class Account : BLL.EntityBase
	{
		#region Constructors
		/// Empty Constructor
		public Account()
		{
			InitializeDateProperties();
		}
		
		// Initialize all the none nullable datetime vars to 1.1.1900 (to avoid SQL crash on insert)
		private void InitializeDateProperties()
		{
		}
		
		/// <summary>
		/// DataRow Constructor
		/// </summary>
		/// <param name="dr"></param>
		internal Account(DataRow dr)
		{
			InitializeDateProperties();
			if (dr.Table.Columns.Contains("ID"))
			{
				ID = Convert.ToInt32(dr["ID"]);
			}

			if (dr.Table.Columns.Contains("ForeignID"))
			{
				if (dr["ForeignID"].GetType() != typeof(DBNull))
					ForeignID = Convert.ToString(dr["ForeignID"]);
				else
					ForeignID = null;
			}

			if (dr.Table.Columns.Contains("Name"))
			{
				if (dr["Name"].GetType() != typeof(DBNull))
					Name = Convert.ToString(dr["Name"]);
				else
					Name = null;
			}

			if (dr.Table.Columns.Contains("FBKey"))
			{
				if (dr["FBKey"].GetType() != typeof(DBNull))
					FBKey = Convert.ToString(dr["FBKey"]);
				else
					FBKey = null;
			}

			if (dr.Table.Columns.Contains("FBSecret"))
			{
				if (dr["FBSecret"].GetType() != typeof(DBNull))
					FBSecret = Convert.ToString(dr["FBSecret"]);
				else
					FBSecret = null;
			}

			if (dr.Table.Columns.Contains("TwKey"))
			{
				if (dr["TwKey"].GetType() != typeof(DBNull))
					TwKey = Convert.ToString(dr["TwKey"]);
				else
					TwKey = null;
			}

			if (dr.Table.Columns.Contains("TwSecret"))
			{
				if (dr["TwSecret"].GetType() != typeof(DBNull))
					TwSecret = Convert.ToString(dr["TwSecret"]);
				else
					TwSecret = null;
			}

		}		
		
		/// <summary>
		/// Explicit Table DataRow Constructor
		/// </summary>
		/// <param name="dr"></param>
		/// <param name="columnPrefix"></param>
		public Account(DataRow dr, string columnPrefix)
		{
			if (dr.Table.Columns.Contains(columnPrefix + "ID"))
			{
				ID = Convert.ToInt32(dr[columnPrefix + "ID"]);
			}

			if (dr.Table.Columns.Contains(columnPrefix + "ForeignID"))
			{
				if (dr[columnPrefix + "ForeignID"].GetType() != typeof(DBNull))
					ForeignID = Convert.ToString(dr[columnPrefix + "ForeignID"]);
				else
					ForeignID = null;
			}

			if (dr.Table.Columns.Contains(columnPrefix + "Name"))
			{
				if (dr[columnPrefix + "Name"].GetType() != typeof(DBNull))
					Name = Convert.ToString(dr[columnPrefix + "Name"]);
				else
					Name = null;
			}

			if (dr.Table.Columns.Contains(columnPrefix + "FBKey"))
			{
				if (dr[columnPrefix + "FBKey"].GetType() != typeof(DBNull))
					FBKey = Convert.ToString(dr[columnPrefix + "FBKey"]);
				else
					FBKey = null;
			}

			if (dr.Table.Columns.Contains(columnPrefix + "FBSecret"))
			{
				if (dr[columnPrefix + "FBSecret"].GetType() != typeof(DBNull))
					FBSecret = Convert.ToString(dr[columnPrefix + "FBSecret"]);
				else
					FBSecret = null;
			}

			if (dr.Table.Columns.Contains(columnPrefix + "TwKey"))
			{
				if (dr[columnPrefix + "TwKey"].GetType() != typeof(DBNull))
					TwKey = Convert.ToString(dr[columnPrefix + "TwKey"]);
				else
					TwKey = null;
			}

			if (dr.Table.Columns.Contains(columnPrefix + "TwSecret"))
			{
				if (dr[columnPrefix + "TwSecret"].GetType() != typeof(DBNull))
					TwSecret = Convert.ToString(dr[columnPrefix + "TwSecret"]);
				else
					TwSecret = null;
			}

		}
		#endregion
		
		
		#region CRUD Methods
		
		public void GetByID(object id)
		{
			BO.Account account = BLL.Accounts.GetByID(id);
			
            ID = account.ID;
            ForeignID = account.ForeignID;
            Name = account.Name;
            FBKey = account.FBKey;
            FBSecret = account.FBSecret;
            TwKey = account.TwKey;
            TwSecret = account.TwSecret;
		}
		public int Insert()
		{
			OnPreInsert();
			return BLL.Accounts.Insert(this);
		}
		
		public override void Update()
		{
			OnPreUpdate();
			BLL.Accounts.Update(this);
		}
		
		public override void Delete()
		{
			OnPreDelete();
			BLL.Accounts.Delete(ID);
		}
		
		public override void SafeDelete()
		{
			OnPreDelete();
			BLL.Accounts.SafeDelete(ID);
		}
		
		public override void SafeDeleteCascade()
		{
			OnPreDelete();
			BLL.Accounts.SafeDeleteCascade(ID);
		}

		#endregion

		#region Properties
		
        public int ID { get; set; }
        public string ForeignID { get; set; }
        public string Name { get; set; }
        public string FBKey { get; set; }
        public string FBSecret { get; set; }
        public string TwKey { get; set; }
        public string TwSecret { get; set; }
		
		#endregion

		
	}
	
	
	[Serializable]
	public partial class FBPage : BLL.EntityBase
	{
		#region Constructors
		/// Empty Constructor
		public FBPage()
		{
			InitializeDateProperties();
		}
		
		// Initialize all the none nullable datetime vars to 1.1.1900 (to avoid SQL crash on insert)
		private void InitializeDateProperties()
		{
		}
		
		/// <summary>
		/// DataRow Constructor
		/// </summary>
		/// <param name="dr"></param>
		internal FBPage(DataRow dr)
		{
			InitializeDateProperties();
			if (dr.Table.Columns.Contains("ID"))
			{
				ID = Convert.ToInt32(dr["ID"]);
			}

			if (dr.Table.Columns.Contains("ForeignID"))
			{
				ForeignID = Convert.ToString(dr["ForeignID"]);
			}

			if (dr.Table.Columns.Contains("Name"))
			{
				Name = Convert.ToString(dr["Name"]);
			}

			if (dr.Table.Columns.Contains("Token"))
			{
				Token = Convert.ToString(dr["Token"]);
			}

		}		
		
		/// <summary>
		/// Explicit Table DataRow Constructor
		/// </summary>
		/// <param name="dr"></param>
		/// <param name="columnPrefix"></param>
		public FBPage(DataRow dr, string columnPrefix)
		{
			if (dr.Table.Columns.Contains(columnPrefix + "ID"))
			{
				ID = Convert.ToInt32(dr[columnPrefix + "ID"]);
			}

			if (dr.Table.Columns.Contains(columnPrefix + "ForeignID"))
			{
				ForeignID = Convert.ToString(dr[columnPrefix + "ForeignID"]);
			}

			if (dr.Table.Columns.Contains(columnPrefix + "Name"))
			{
				Name = Convert.ToString(dr[columnPrefix + "Name"]);
			}

			if (dr.Table.Columns.Contains(columnPrefix + "Token"))
			{
				Token = Convert.ToString(dr[columnPrefix + "Token"]);
			}

		}
		#endregion
		
		
		#region CRUD Methods
		
		public void GetByID(object id)
		{
			BO.FBPage fBPage = BLL.FBPages.GetByID(id);
			
            ID = fBPage.ID;
            ForeignID = fBPage.ForeignID;
            Name = fBPage.Name;
            Token = fBPage.Token;
		}
		public int Insert()
		{
			OnPreInsert();
			return BLL.FBPages.Insert(this);
		}
		
		public override void Update()
		{
			OnPreUpdate();
			BLL.FBPages.Update(this);
		}
		
		public override void Delete()
		{
			OnPreDelete();
			BLL.FBPages.Delete(ID);
		}
		
		public override void SafeDelete()
		{
			OnPreDelete();
			BLL.FBPages.SafeDelete(ID);
		}
		
		public override void SafeDeleteCascade()
		{
			OnPreDelete();
			BLL.FBPages.SafeDeleteCascade(ID);
		}

		#endregion

		#region Properties
		
        public int ID { get; set; }
        public string ForeignID { get; set; }
        public string Name { get; set; }
        public string Token { get; set; }
		
		#endregion

		
	}
	
	
	[Serializable]
	public partial class Post : BLL.EntityBase
	{
		#region Constructors
		/// Empty Constructor
		public Post()
		{
			InitializeDateProperties();
		}
		
		// Initialize all the none nullable datetime vars to 1.1.1900 (to avoid SQL crash on insert)
		private void InitializeDateProperties()
		{
			Date = new DateTime(1900,1,1);
		}
		
		/// <summary>
		/// DataRow Constructor
		/// </summary>
		/// <param name="dr"></param>
		internal Post(DataRow dr)
		{
			InitializeDateProperties();
			if (dr.Table.Columns.Contains("ID"))
			{
				ID = Convert.ToInt32(dr["ID"]);
			}

			if (dr.Table.Columns.Contains("Type"))
			{
				Type = Convert.ToInt32(dr["Type"]);
			}

			if (dr.Table.Columns.Contains("Text"))
			{
				Text = Convert.ToString(dr["Text"]);
			}

			if (dr.Table.Columns.Contains("AccountID"))
			{
				if (dr["AccountID"].GetType() != typeof(DBNull))
					AccountID = Convert.ToInt32(dr["AccountID"]);
				else
					AccountID = null;
			}

			if (dr.Table.Columns.Contains("PageID"))
			{
				if (dr["PageID"].GetType() != typeof(DBNull))
					PageID = Convert.ToInt32(dr["PageID"]);
				else
					PageID = null;
			}

			if (dr.Table.Columns.Contains("Sentiment"))
			{
				if (dr["Sentiment"].GetType() != typeof(DBNull))
					Sentiment = Convert.ToDouble(dr["Sentiment"]);
				else
					Sentiment = null;
			}

			if (dr.Table.Columns.Contains("ParentID"))
			{
				if (dr["ParentID"].GetType() != typeof(DBNull))
					ParentID = Convert.ToInt32(dr["ParentID"]);
				else
					ParentID = null;
			}

			if (dr.Table.Columns.Contains("ForeignID"))
			{
				ForeignID = Convert.ToString(dr["ForeignID"]);
			}

			if (dr.Table.Columns.Contains("Date"))
			{
				Date = Convert.ToDateTime(dr["Date"]);
			}

			if (dr.Table.Columns.Contains("FromUserName"))
			{
				FromUserName = Convert.ToString(dr["FromUserName"]);
			}

			if (dr.Table.Columns.Contains("SapID"))
			{
				if (dr["SapID"].GetType() != typeof(DBNull))
					SapID = Convert.ToString(dr["SapID"]);
				else
					SapID = null;
			}

		}		
		
		/// <summary>
		/// Explicit Table DataRow Constructor
		/// </summary>
		/// <param name="dr"></param>
		/// <param name="columnPrefix"></param>
		public Post(DataRow dr, string columnPrefix)
		{
			if (dr.Table.Columns.Contains(columnPrefix + "ID"))
			{
				ID = Convert.ToInt32(dr[columnPrefix + "ID"]);
			}

			if (dr.Table.Columns.Contains(columnPrefix + "Type"))
			{
				Type = Convert.ToInt32(dr[columnPrefix + "Type"]);
			}

			if (dr.Table.Columns.Contains(columnPrefix + "Text"))
			{
				Text = Convert.ToString(dr[columnPrefix + "Text"]);
			}

			if (dr.Table.Columns.Contains(columnPrefix + "AccountID"))
			{
				if (dr[columnPrefix + "AccountID"].GetType() != typeof(DBNull))
					AccountID = Convert.ToInt32(dr[columnPrefix + "AccountID"]);
				else
					AccountID = null;
			}

			if (dr.Table.Columns.Contains(columnPrefix + "PageID"))
			{
				if (dr[columnPrefix + "PageID"].GetType() != typeof(DBNull))
					PageID = Convert.ToInt32(dr[columnPrefix + "PageID"]);
				else
					PageID = null;
			}

			if (dr.Table.Columns.Contains(columnPrefix + "Sentiment"))
			{
				if (dr[columnPrefix + "Sentiment"].GetType() != typeof(DBNull))
					Sentiment = Convert.ToDouble(dr[columnPrefix + "Sentiment"]);
				else
					Sentiment = null;
			}

			if (dr.Table.Columns.Contains(columnPrefix + "ParentID"))
			{
				if (dr[columnPrefix + "ParentID"].GetType() != typeof(DBNull))
					ParentID = Convert.ToInt32(dr[columnPrefix + "ParentID"]);
				else
					ParentID = null;
			}

			if (dr.Table.Columns.Contains(columnPrefix + "ForeignID"))
			{
				ForeignID = Convert.ToString(dr[columnPrefix + "ForeignID"]);
			}

			if (dr.Table.Columns.Contains(columnPrefix + "Date"))
			{
				Date = Convert.ToDateTime(dr[columnPrefix + "Date"]);
			}

			if (dr.Table.Columns.Contains(columnPrefix + "FromUserName"))
			{
				FromUserName = Convert.ToString(dr[columnPrefix + "FromUserName"]);
			}

			if (dr.Table.Columns.Contains(columnPrefix + "SapID"))
			{
				if (dr[columnPrefix + "SapID"].GetType() != typeof(DBNull))
					SapID = Convert.ToString(dr[columnPrefix + "SapID"]);
				else
					SapID = null;
			}

		}
		#endregion
		
		
		#region CRUD Methods
		
		public void GetByID(object id)
		{
			BO.Post post = BLL.Posts.GetByID(id);
			
            ID = post.ID;
            Type = post.Type;
            Text = post.Text;
            AccountID = post.AccountID;
            PageID = post.PageID;
            Sentiment = post.Sentiment;
            ParentID = post.ParentID;
            ForeignID = post.ForeignID;
            Date = post.Date;
            FromUserName = post.FromUserName;
            SapID = post.SapID;
		}
		public int Insert()
		{
			OnPreInsert();
			return BLL.Posts.Insert(this);
		}
		
		public override void Update()
		{
			OnPreUpdate();
			BLL.Posts.Update(this);
		}
		
		public override void Delete()
		{
			OnPreDelete();
			BLL.Posts.Delete(ID);
		}
		
		public override void SafeDelete()
		{
			OnPreDelete();
			BLL.Posts.SafeDelete(ID);
		}
		
		public override void SafeDeleteCascade()
		{
			OnPreDelete();
			BLL.Posts.SafeDeleteCascade(ID);
		}

		#endregion

		#region Properties
		
        public int ID { get; set; }
        public int Type { get; set; }
        public string Text { get; set; }
        public int? AccountID { get; set; }
        public int? PageID { get; set; }
        public double? Sentiment { get; set; }
        public int? ParentID { get; set; }
        public string ForeignID { get; set; }
        public DateTime Date { get; set; }
        public string FromUserName { get; set; }
        public string SapID { get; set; }
		
		#endregion

		
	}
	
}



